Page({
  data: {
    list: [],
    dates: [],
    loadingHidden: false
  },
  onLoad: function (options) {
    // 页面初始化 options为页面跳转所带来的参数
    //加载最新
    this.requestData('newlist');
  },

  /**
   * 上拉刷新
   */
  bindscrolltoupper: function () {
    //加载最新
    // this.requestData('newlist');
  },

  /**
   * 加载更多
   */
  bindscrolltolower: function () {
    console.log('到底部')
    //加载更多
    this.requestData('list');
  },

  requestData: function () {
    var that = this;
    wx.request({
      url: getApp().globalData.ADMIN_API_HOST +
      '/appointments/?1=1',
      data: {
        customer_id: getApp().globalData.customer.id,
        status: 'undefined',
      },
      method: 'GET',
      success: function (res) {
        if (res.data.isSuccess) {
          that.setData({
            loadingHidden: true,
            dates: res.data.dates,
            list: res.data.data
          })
        } else {
          wx.showToast({
            title: '网络请求失败',
            icon: 'loading',
            duration: 2000
          });
        }
      }
    })
  },


  onReady: function () {
    // 页面渲染完成
  },
  onShow: function () {
    // 页面显示
  },
  onHide: function () {
    // 页面隐藏
  },
  onUnload: function () {
    // 页面关闭
  }
})